<SCRIPT LANGUAGE="JavaScript"> 
    function swap(id)
    {
        var temp = "page"+id;
        document.getElementById('search_result').innerHTML = document.getElementById(temp).innerHTML;
    }   
    
    function open_win(id)
    {
        window.open('../jobseekers/preview_resume/'+id,"_blank","toolbar=no, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, top=100, left=100, width=850, height=600");
    }     
</SCRIPT>

<?php
echo $this->Element('myfunction');
echo "<div class='form'>"; 
echo "<h2> Resume Search Result </h2>";
echo "<hr color='#2A7EF7'>";    
echo ":. Start new resume search ".$html->link('[ Resume Search ]',array('controller'=>'resumes','action'=>'search'))."<br />";

    $max_record = RECORD_PER_PAGE;
    $jum_record = count($data);
    $page = floor($jum_record / $max_record);
    if($jum_record % $max_record != 0)
    { $page++; }
    $record = 0;
    
    echo "<br />&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp <b>.: The Resume Search Result :.</b>";
    echo "<div id='search_result'>";
    if(count($data)==0)
    { echo "&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp <span class='red'>* There is no data resumes in your search</span>"; }
    echo"</div>";              
    for($i=1; $i<=$page; $i++)
    {
        echo "<div id='page".$i."' style='display:none'>";
        echo "<table class='jobs' cellpadding=0 cellspacing=0 style='margin-top:3px'> ";
        echo "<tr><th width='100px'>Last Updated</th><th width='200px'>Name</th><th width='80px'>Gender</th><th width='30px'>Age</th><th width='100px'>Location</th><th width='160px'>Highest Academic</th><th width='160px'>Working Experience</th><th width='150px'>Action</th></tr>";
        for ($j=0; $j<$max_record; $j++)
        {
            if( $record < $jum_record )
            {
                echo "<tr>";
                    echo "<td>".mydate($data[$record]['resumes']['modified'])."</td>";
                    echo "<td>".$data[$record]['jobseekers']['salution']." ".$data[$record]['jobseekers']['first_name']." ".$data[$record]['jobseekers']['last_name']."</td>";
                    echo "<td>".$data[$record]['jobseekers']['gender']."</td>";
                    $age = ( date("Y")-substr($data[$record]['jobseekers']['date_of_birth'],0,4) );
                    echo "<td>".$age."</td>";
                    
                    foreach($academics as $academic)
                    {
                        if($academic['academics']['id']==$data[$record]['resumes']['academic_id'])
                        { $academic_name = $academic['academics']['name']; }
                    }
                    foreach($cities as $city)
                    {
                        if($city['cities']['id']==$data[$record]['jobseekers']['city_id'])
                        { $city_name = $city['cities']['name']; }
                    }
                    
                    echo "<td>".$city_name."</td>";
                    echo "<td>".$academic_name."</td>";

                    if($data[$record]['resumes']['work_exp']==0)
                    echo "<td> Still School </td>";
                    if($data[$record]['resumes']['work_exp']==1)
                    echo "<td> Fresh Graduate </td>";
                    if($data[$record]['resumes']['work_exp']==2)
                    echo "<td>".$data[$record]['resumes']['year_exp']." years</td>";

                    echo "<input type='hidden' id='email".$data[$record]['jobseekers']['id']."' value='".$data[$record]['jobseekers']['email']."'>";
                    echo "<td><a href='Javascript:open_win(".$data[$record]['jobseekers']['id'].")' class='sky'>[ View ]</a> &nbsp <a href='mailto:".$data[$record]['jobseekers']['email']."?subject=ITjobz.com, Resume Request' class='sky'>[ Email ]</a></td>";
                    //echo "<td><a href='Javascript:haha(".$data[$record]['jobseekers']['email'].")'> Email </a></td>";
                                           
                echo "</tr>";
                $record++;
            }
        }
        
        echo "<tr class='end'>";
        if($page!=1)
        {
            if($i==1)
            { echo "<td class='end' colspan=7> </td><td style='text-align:right' class='end'><a href='javascript:swap(".($i+1).")'>Next >></a> &nbsp</td>"; }

            if($i!=1 && $i!=$page)
            { 
                echo "<td class='end'>&nbsp <a href='javascript:swap(".($i-1).")'><< Prev</a></td>"; 
                echo "<td class='end' style='text-align:right' colspan=7><a href='javascript:swap(".($i+1).")'>Next >></a> &nbsp</td>";
            }
            
            if($i==$page)
            { echo "<td class='end' colspan=7>&nbsp <a href='javascript:swap(".($i-1).")'><< Prev</a></td><td class='end'> </td>"; }
        }        
        else
        { echo "<td class='end' colspan=8>&nbsp</td>"; }
        echo "</tr>";
        echo "</table>";
        echo "</div>";
    }    

echo "</div>";
?>

<SCRIPT LANGUAGE="JavaScript"> 
        document.getElementById('search_result').innerHTML = document.getElementById('page1').innerHTML;
</SCRIPT>